var express = require("express");
var router = express.Router();
const jwt = require("jsonwebtoken");
const { sercetKey } = require("./../config");

router.post("/", (req, res) => {
  if (req.body.username !== "admin" || req.body.password !== "123456") {
    return res.send({ status: 1, mes: "登录失败" });
  }
  const tokenStr = jwt.sign({ username: req.body.username }, sercetKey, {
    expiresIn: "30s",
  });

  res.send({ status: 0, mes: "登录成功！", token: tokenStr });
});

module.exports = router;
